/*------------------------------------------------------
                hou_elearningGEN beta v1.0
Author: xtrung.net@gmail.com
Write On: 04/27/2008
Create On:4/13/2012 11:23:00 AM
------------------------------------------------------*/
using hou_elearning.DataAccess.Base;
using hou_elearning.Entity;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
using System.Collections;
using System.Web;

namespace hou_elearning.DataAccess
{
    public class DanhmucsukienslideDAL : SqlProvider<DanhmucsukienslideEntity>
    {
        static DanhmucsukienslideDAL()
        {
            InitReader();
        }
        protected static void InitReader()
        {
            getFromReader=delegate(SqlDataReader dr)
            {
                DanhmucsukienslideEntity entity = new DanhmucsukienslideEntity();
                entity.PK_sDanhmucsukienslideID = dr["PK_sDanhmucsukienslideID"].ToString();
				entity.sTensukien = dr["sTensukien"].ToString();
                entity.sGhichu = dr["sGhichu"].ToString();
                return entity;
            };
        }
        public static DanhmucsukienslideEntity GetOne(String PK_sDanhmucsukienslideID)
        {
            string cmdName = "spDanhmucsukienslide_GetByPK";
            SqlParameter p = new SqlParameter("@PK_iDanhmucsukienslideID", PK_sDanhmucsukienslideID);
            DanhmucsukienslideEntity entity = GetOne(cmdName, p);
            return entity;
        }
        public static List<DanhmucsukienslideEntity> GetAll()
        {
            string cmdName = "spDanhmucsukienslide_Get";
            return GetList(cmdName);
        }
        
        public static int Add(DanhmucsukienslideEntity entity)
        {
            string cmdName = "spDanhmucsukienslide_Insert";
            return Run(cmdName,true,initParams(entity));

        }
        public static bool Edit(DanhmucsukienslideEntity entity)
        {
            string cmdName = "spDanhmucsukienslide_Update";
            return Run(cmdName,false,initParams(entity))>0;
        }
        public static bool Remove(String PK_sDanhmucsukienslideID)
        {
            string cmdName = "spDanhmucsukienslide_Delete";
            SqlParameter p = new SqlParameter("@PK_sDanhmucsukienslideID", PK_sDanhmucsukienslideID);
            return Run(cmdName,false,p)>0;
        }
        #region private
        private static SqlParameter[] initParams(DanhmucsukienslideEntity entity)
        {
            SqlParameter[] p = new SqlParameter[3];
			p[0] = new SqlParameter("@PK_sDanhmucsukienslideID", entity.PK_sDanhmucsukienslideID);
			p[1] = new SqlParameter("@sTendanhmuc", entity.sTensukien);
            p[2] = new SqlParameter("@sGhichu", entity.sTensukien);
            return p;
        }
        #endregion
       
    }
}